package demo;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘远望
 * Date: 2025-03-23
 * Time: 10:33
 */
class Login{
    private String name;
    private String password;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    public void logInfo(String name,String password)
            throws PassWordException {
        if(!this.name.equals(name)){
            throw new NameException("名字错误");
        }

        if(!this.password.equals(password)) {
            throw new PassWordException("密码错误");
        }

        System.out.println("登录成功");
    }
}
public class Test {
    public static void main(String[] args) {
        Login login = new Login();
        login.setName("Lyw");
        login.setPassword("666");
        try {
            login.logInfo("Lyw", "6");
        }catch (NameException e){
            e.printStackTrace();
        }catch (PassWordException e){
            e.printStackTrace();
        } finally {

        }

    }
}
